﻿<script>
$(document).ready(function() {
	$("#depositForm").validate({
		   rules:{
			 balance:{required:true,amount:true}
		   },
		   messages:{
			 balance:{required:"This field is required.",amount:"Please enter a valid number!"}		
		   },
		   errorPlacement:function(error, element){
				$("<img src=\'/images/error.jpg\'>").prependTo(error);			 
				element.parent().parent().children(".right").html(error);  
			},
			success:function(label){
				label.parent().parent().children(".right").html("<img src='/images/yes.gif'>");
			}
	});


	
});


function payConf(){
	var currency = $('[name=currency]').val();
	var balance = $('[name=balance]').val();
	var depositType = $('[name=depositType]').val(); 
	 
	if($("#depositForm").valid()==false) return;
	 loading();
	 $(".message").html('');
	 $.ajax({ //这里使用到Jquery的ajax方法
	  type: "POST",
	  async: false,
	  dataType: "json",
	  url: "/merchant/my-account/deposit-order", //请求的处理url
	  data:{
			'currency':currency,'balance':balance,'depositType':depositType			
			}, 
	  success: function(json) { 
	    
		 if(json.ask=="Success"){	 
			window.location.href=json.url;
		 }else{
			html ='<span style="color: red;">'+json.message+' </span>';
			$(".message").html(html);
			 
		 }
		 
		 closeLoading();
	  }
	}); 
}

</script> 
<div class="position" style="margin:-20px 0 0 5px;"><a href='/default/index'>Home</a> &gt; <a href='/merchant/my-account'>Merchant Center</a>  &gt; My Account &gt; Deposid Fund </div>
<div class="merchant-content" style="border-bottom: 1px solid #CCCCCC;">
<H4>Deposit My Account</H4>
 

<div class="account-tab-div" style="background:#FFF8DB; border-left:1px #CCCCCC solid; border-right:1px #CCCCCC solid;">

<form class="depositForm" id="depositForm" method="post" action="#">

	<div class="row height25">
		<div class="left" style="width:120px;">Deposit Amount: </div>
		<div class="middle">
			<input style="margin-top:-2px;" id="balance" value="" maxlength="32" name="balance"/>
			<span class="red">&nbsp;&nbsp;*</span>
		</div>
		<div class="right">Enter your deposit amount</div>
		<div class="clearFloat"></div>
								
	</div>
	<div class="row height25">
		<div class="left" style="width:120px;">Currency: </div>
		<div class="middle" style="margin-bottom:3px; ">
			<select id="currency" style="width:130px;"name="currency">
			<option value="USD">USD</option>
			<option value="EUR">EUR</option>
			<option value="GBP">GBP</option>
			<option value="CAD">CAD</option>
			</select>
		</div>
		<div class="right">
			Select currency
		</div>
		<div class="clearFloat"></div>
								
	</div>
</form>	
	
</div>
<div  align="center" style="margin-top:20px">
<div class="message" style="margin-top:5px"></div>
		 <input id="depositType"   value="paypal"   name="depositType" type="hidden"/>
			<input type="image" src='https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif' border='0' align='top' alt='PayPal' onclick="payConf();" />
		 
		 
								
	</div>

              
 
</div>	

  